﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HamcoWcs.Models.Monitors
{
    public class ThresholdMonitor
    {
        public string FieldName { get; set; }
        public int Offset { get; set; }
        public short Value { get; set; }

        public short Cmd { get; set; }
        public string Unit1 { get; set; }
        public string Unit2 { get; set; }
        public int Gain { get; set; }

        public ThresholdMonitor(string fieldName, int offset, string unit1 = "", string unit2 = "", int gain = 1)
        {
            FieldName = fieldName;
            Offset = offset;
            Unit1 = unit1;
            Unit2 = unit2;
            Gain = gain;
        }

        public void Update(byte[] content)
        {
            var t = content.Skip(Offset).Take(2).Reverse().ToArray();
            Value = BitConverter.ToInt16(t);
        }
    }
}
